package com.Stream.A01StreamLiu;

import java.util.*;
import java.util.stream.Collectors;

public class A10_Stream {
    public static void main(String[] args) {
        /*
            收集方法 collect

        * */

        ArrayList<String> list = new ArrayList<>();
        Collections.addAll(list,"张无忌-男-15","周芷若-女-14","赵敏-女-13","张强-男-20","张三丰-男-100","张翠山-男-40","张良-男-35","王二麻子-男-37","谢广坤-男-41");


        /*
            需求
                把男性收集起来
        * */
        List<String> collect = list.stream().filter(s -> "男".equals(s.split("-")[1])).collect(Collectors.toList());
        System.out.println(collect);


        Set<String> collect2 = list.stream().filter(s -> "男".equals(s.split("-")[1])).collect(Collectors.toSet());
        System.out.println(collect2);

        Map<String, String> map = list.stream().filter(s -> "男".equals(s.split("-")[1])).collect(Collectors.toMap(s -> s.split("-")[0], s -> s));
        System.out.println(map);
    }
}
